Latest Microsoft Dynamics 365 Blogs | CloudFronts

Use of Vendor and Customer Workflow in Dynamics NAV

Introduction: We all have noticed Send Approval Request button on Vendor and Customer pages. You can select Customer workflow from the workflow template Sales and Marketing. Vendor  can be configured similar to customer workflow. These standard workflows can be enabled from the workflow page….but what’s the use of it? why do we need it? This blog explains the use of Vendor, Customer workflow in Dynamics NAV. Pre-requisites: Microsoft Dynamics NAV 2016. Steps: 1. Enable the Vendor, Customer, Item workflow: Browse to workflows and select new workflow from Template and under the Sales and Marketing select Customer Approval workflow. In the workflow response select the workflow user group or direct approver to which approval will be sent. Similarly, configure Item and Vendor workflow. 2. Send the Customer for Approval: In the Customer Card page click on Send approval request to sent the customer for approval. Once approval is sent. Workflow Factbox appears on the right hand side. 3. Use of the workflow: Customer Workflow Now this workflow is sent for approval but not approved. If you navigate to sales order and use the same Customer. If you post the sales order or Journal, you will get the below error. Once the customer is approved, Sales order is approved successfully. Vendor Workflow: Send the Vendor for approval by clicking on Send approval request. Workflow factbox is visible. Now when you post the Purchase order or  journal for account type Vendor you will get the below error. Once its approved, The journal lines is posted.

Share Story :

How to create Cue tiles for Role center in Dynamics NAV 2017

Introduction: Cues are designed to give users with a quick status of their daily activities, which acts as a prompt them to take action. A Cue is a tile on a page in the Dynamics NAV client that provides a visual representation of business data. This blog explains how to create cue tiles to get visual representation of Net Invoices and and payment received for current week, month and year. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. Create fields in a table as below: Enabled Field No. Field Name Data Type Length Description Yes 26 Net Invoicing this Week Decimal Chris Yes 27 Net Invoicing MTD Decimal Chris Yes 28 Net Invoicing YTD Decimal Chris Yes 6 Payment Recieved this week Decimal Chris Yes 7 Payment Received this month Decimal chris Yes 37 Payment received YTD Decimal Chris 2. Create a Query. select DataItem as Cust. Ledger Entry and enter the fields as Filter and add a column as Amount and use the method type as Totals and Method as Sum 3. For Invoices Received this week: Create a global function in the table Calculate Invoice Received this week week with return type as Decimal. For this requirement, the week start day is Sunday and end day is Saturday but by default in Dynamics NAV, the week start day is Monday and end day is Sunday. So in NAV 1 = Monday and 7 = Sunday.  So I’ve written the below code to get the weeks start date and end date. TodayDateNo:=DATE2DWY(TODAY,1); //this code fetches which day of the week is today e.g its Friday it returns 5. I’ve declared two global  variables StartDateofWeek1 and EndDateofWeek1 and local record variable  and added the below code: CalculateInvoicetReceivedThisWeek() AmtWeek : Decimal TodayDateNo:=DATE2DWY(TODAY,1); IF TodayDateNo =1 THEN BEGIN //Monday StartDateOfWeek1:=CALCDATE(‘< -1D >’,TODAY); //Sunday EndDateOfWeek1 := CALCDATE(‘< +5D >’,TODAY); //Saturday END; IF TodayDateNo =2 THEN BEGIN //Tuesday StartDateOfWeek1:=CALCDATE(‘< -2D >’,TODAY); EndDateOfWeek1 := CALCDATE(‘<+4D>’,TODAY); END; IF TodayDateNo =3 THEN BEGIN //Wednesday StartDateOfWeek1:=CALCDATE(‘< -3D >’,TODAY); EndDateOfWeek1 := CALCDATE(‘<+3D>’,TODAY); END; IF TodayDateNo =4 THEN BEGIN //Thursday StartDateOfWeek1:=CALCDATE(‘< -4D >’,TODAY); EndDateOfWeek1 := CALCDATE(‘<+2D>’,TODAY); END; IF TodayDateNo =5 THEN BEGIN //Friday StartDateOfWeek1:=CALCDATE(‘< -5D >’,TODAY); EndDateOfWeek1 := CALCDATE(‘<+1D>’,TODAY); END; IF TodayDateNo =6 THEN BEGIN //Saturday StartDateOfWeek1:=CALCDATE(‘< -6D >’,TODAY); EndDateOfWeek1 := TODAY; END; IF TodayDateNo =7 THEN BEGIN //Sunday StartDateOfWeek1:=TODAY; EndDateOfWeek1 := CALCDATE(‘< +6D >’,TODAY); END; I’m using a Query to get the sum of invoices for the current week CF_Query.SETRANGE(Document_Type,CustLedgerEntry.”Document Type”::Invoice,CustLedgerEntry.”Document Type”::”Credit Memo”); CF_Query.SETRANGE(Posting_Date,CALCDATE(‘<CW>’,StartDateOfWeek1),EndDateOfWeek1); CF_Query.OPEN; IF CF_Query.READ THEN AmtWeek:=CF_Query.Sum_Payment; 4. For Invoice received this Month: Create a global function as below with return type as decimal and insert the below code CalculateInvoiceReceivedThisMonth() AmtMonth : Decimal //This query fetches data from 1st date of current month till today CF_Query.SETRANGE(Document_Type,CustLedgerEntry.”Document Type”::Invoice,CustLedgerEntry.”Document Type”::”Credit Memo”); CF_Query.SETRANGE(Posting_Date,CALCDATE(‘<-CM>’,TODAY),TODAY); CF_Query.OPEN; IF CF_Query.READ THEN AmtMonth:=CF_Query.Sum_Payment; 5. For Invoices received this Year: Create a global function as below with return type as decimal and insert the below code: CalculateInvoiceReceivedThisYear() AmtYear : Decimal //This query fetches data from start date of the year i.e 1 Jan till today CF_Query1.SETRANGE(Document_Type,CustLedgerEntry.”Document Type”::Invoice,CustLedgerEntry.”Document Type”::”Credit Memo”); CF_Query1.SETRANGE(Posting_Date,CALCDATE(‘<-CY>’,TODAY),TODAY); CF_Query1.OPEN; IF CF_Query1.READ THEN AmtYear:=CF_Query1.Sum_Payment; 6. For Payments received same code is used as above only in the query the setfilter condition is changed to Payments e.g for Payments received this year the code is as below: CalculatePaymnetReceivedThisYear() AmtYr1 : Decimal CF_Query.SETFILTER(Document_Type,’%1|%2′,CustLedgerEntry.”Document Type”::Payment,CustLedgerEntry.”Document Type”::Refund); CF_Query.SETRANGE(Posting_Date,CALCDATE(‘<-CY>’,TODAY),TODAY); CF_Query.OPEN; IF CF_Query.READ THEN AmtYr1:=CF_Query.Sum_Payment; 7. Now you need to call these functions, we will call them from the Cue page. create a page and create a group with subtype as CueGroup. Add your fields below the group 8. On OnOpenPage of the Cue page write the below code OnOpenPage() RESET; IF NOT GET THEN BEGIN INIT; INSERT; END; OnAfterGetRecord() CalculateCueFields; 9. On the trigger OnAfterGetRecord, a local function is called CalculateCueFields.In this function, call is made to the functions for invoices and payments. LOCAL CalculateCueFields() IF FIELDACTIVE(“Net Invoicing this Week”) THEN “Net Invoicing this Week”:=CalculateInvoicetReceivedThisWeek; IF FIELDACTIVE(“Net Invoicing MTD”) THEN “Net Invoicing MTD”:=CalculateInvoiceReceivedThisMonth; IF FIELDACTIVE(“Net Invoicing YTD”) THEN “Net Invoicing YTD”:=CalculateInvoiceReceivedThisYear; IF FIELDACTIVE(“Payment Recieved this week”) THEN “Payment Recieved this week”:=CalculatePaymnetReceivedThisWeek; IF FIELDACTIVE(“Payment Received this month”) THEN “Payment Received this month”:=CalculatePaymnetReceivedThisMonth; IF FIELDACTIVE(“Payment received YTD”) THEN “Payment received YTD”:=CalculatePaymnetReceivedThisYear; Run the page : 10. Drilldown: Suppose the user wants to check for the entries which account for Net Invoicing MTD to 718.00 then create a global function in the table DrillDownInvoiceThisMonth , create a record variable CustLedgerEntry and write the below code: DrillDownInvoiceThisMonth() CustLedgerEntry.SETRANGE(“Document Type”,CustLedgerEntry.”Document Type”::Invoice,CustLedgerEntry.”Document Type”::”Credit Memo”); CustLedgerEntry.SETRANGE(“Posting Date”,CALCDATE(‘<-CM>’,TODAY),TODAY); PAGE.RUN(PAGE::”Customerer Entries”,CustLedgerEntry); Call this function in the page, under the field Net Invoicing MTD – OnDrillDown() Net Invoicing MTD – OnDrillDown() DrillDownInvoiceThisMonth

Share Story :

How to send Email Notification to Users using Workflow in Dynamics NAV

Introduction: Many a times in an Approval workflow, we need to notify the user by email to the Approver that approval request is sent also the sender needs to be notified whether the approval request sent is approved or cancelled. Hence, we need to setup Email Notification. Pre-requisites: Microsoft Dynamics NAV 2016 Office 365 Account Steps: 1. Setup SMTP Mail Setup Navigate to SMTP Mail setup from the Search bar. Click on Apply Office 365 Server Settings. Enter the UserID and Password (This is the sender’s email id. Mostly company email) 2. Setup Notification Template and Notification Setup Navigate to Notification Template and set Notification Method to E-mail for Type Approval Navigate to Notification Setup, for Notification Type Approval Schedule it Instantly.It can also be schedules Daily, Weekly, Monthly 3. Setup emails in the Approval User Setup In the Approval User Setup, enter the email id of each user in the email field. 4. Enable Mail Notify Job Queue. Navigate to the Job queue and enable Notify Job queue. The Mail Notify job queue is a standard job queue. When workflow is triggered having response Send approval request for the record and create a notification, Notification Entry is created in the Notification entries Record. This job fetches records from Notification entries and sends email to the recipient. The sent email can be viewed in the Sent Notification Entries page. Note: Delete the pre-existing Notification Entries of users with no email id or entries prior setting up emails 5. Sending email to the approver from workflow I’ve enabled standard Purchase Quote workflow. Open Purchase Quote and click on Send Approval Request. The status of the Purchase Quote changes to Pending Approval A notification email is sent to the approver.

Share Story :

How to Send Mail with attachment using Streams for reports with request page in Dynamics NAV

Scenario: On Customer Master page, an action button is created called Email customer, on click of the action button, an email has to be sent to the respective customer with attachment of the invoices in a .pdf format. Here, the report is saves as .pdf file. This report has a request page where Start Date and End date are entered by the user. Based on the date ranges, invoices generated for the particular user is mailed to the customer. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. Create a global function on the Customer master page to make a call to the codeunit. Here the Customer No. is passed as a parameter. 2. In the Function InvoiceMail, declare a parameter  CustNo. and the variables as follows: Here CustTempTable is a Temporary table The Code is added as follows: InvoiceMail(Custno : Code[20]) -Function Name SMTPMailSetup.GET; CustomerTable.RESET; CustomerTable.SETRANGE(“No.”,Custno); IF CustomerTable.FINDFIRST THEN BEGIN EmailID:=CustomerTable.”E-Mail”; CF_FTLCustomerInvoice.SETTABLEVIEW(CustomerTable); XmlParameters:=CF_FTLCustomerInvoice.RUNREQUESTPAGE(); CustTempTable.Parameters.CREATEOUTSTREAM(OStream,TEXTENCODING::UTF8); CustTempTable.Parameters.CREATEINSTREAM(IStream,TEXTENCODING::UTF8); REPORT.SAVEAS(50011,XmlParameters,REPORTFORMAT::Pdf,OStream); CLEAR(SMTPMail); SMTPMail.CreateMessage(”,SMTPMailSetup.”User ID”,EmailID,’Invoice Statement from CompanyName‘,”,TRUE); SMTPMail.AddAttachmentStream(IStream,’Customer Invoice’+ CustomerTable.Name+’.pdf’); SMTPMail.AppendBody(‘Hi ‘+CustomerTable.Name+’,’); SMTPMail.AppendBody(‘<br>’); SMTPMail.AppendBody(‘Please find attached your Customer Invoice statement’); SMTPMail.AppendBody(‘<HR>’); SMTPMail.AppendBody(‘This is a system generated mail. Please do not reply to this mail!’); SMTPMail.Send; MESSAGE(‘Mail sent to Customer %1’,Custno); END; Explaination of the code: 1. Set the SMTL Mail setup in the Role Tailored Client. Click on Apply Office 365 Server Settings. Add the Sender email (comapny email in my case) in User ID field and password of the email id in the Password field. 2. Store the Customer Email in the Email ID variable. 3. Pass the filters applied to the CustomerTable to the report variable CF_FTLCustomerInvoice. 4. Run the request page. The Run request page passes the request parameters in an xml format which is stored in a text variable XmlParameters. 5. Create an OutStream to save the the XmlParamters received in a File Parameters in a .xml format. 6. Create Instream to read the .xml file. 7. REPORT.SAVEAS(50011,XmlParameters,REPORTFORMAT::Pdf,OStream); saves the xmlparameters from the outsream in an pdf format. 8. Use SMTPMail.CreateMessage function to enter the sender’s and receipient’s  email, Subject  etc. 9. Add the attachement from the InputStream. 10. Draft a body of the email and Use SMTPMail.Send to Send the email. Yay.Email is Sent! Execution: 1.Click on Action button, Request page opens. 2. Enter the Start date and End date and click on OK. 3. An email is sent to the customer. Conclusion: Overview of the blog, first setup the SMTL Mail setup. Create an action button and create a function call. In the function defination, code as above and email is sent

Share Story :

How to change the font colour of a List page based on a condition in Dynamics NAV

Intoduction: The requirement was such that, based on a condition certain lines should appear in Red.This can be done by using page control Style Property. The Style property has ten values that apply different formats to field text as below: Value Format Standard Standard StandardAccent Blue Strong Bold StrongAccent Blue + Bold Attention Red + Italic AttentionAccent Blue + Italic Favorable Bold + Green Unfavorable Bold + Italic + Red Ambiguous Yellow Subordinate Grey Pre-Requisites: Microosft Dynamics NAV 2017 Steps: 1. Create a global variable i.e. on the View menu, choose C/AL Globals. 2. Define the variable, and then set the DataType to Boolean. 3. Open the Property of the variable then set the IncludeInDataSet to Yes. (I’ve use CFS_Repo as my boolean field). 4. Create a local function. (in my case UpdateStyle). 5. Now, code in the function. My requiremnt was such that if field  RepoInitiated is true then the line should should appear red. You can code as per tour requirement. 6. On the trigger OnAfterGetCurrRecord, call the function. 7. Now select the Field in the List page and click on Properties (Shift + F4) 8. Set the Style to Unfavorable and StyleExpr to CFS_Repo (the boolean field ) 9. Repeat the step 8 for all fields present on the list page.

Share Story :

How to update the selected line in the Subform on click of an action button in the Mainform in NAV

Introduction: The requirement was such that , the user will select a line in the subform. The subform has fields like the Customer ID, Customer Name, and a field Recieved Crates. On click of the action button in the Main form, a page opens which contains the details of the selected line in the subform  like Customer ID and Customer Name also a field Crate recieved(Integer Datatype). User will enter Crate Recieved and click on OK. The number entered in the Crate received will modify in the Recieved crates field in the subform. This blog explains the step wise procedure to achieve the above output. Pre-Requisites: Microsoft Dynamics NAV 2017 Steps: 1. Open the Developement Environment of Microsoft Dynamics NAV and open the Main form(card Page) and create an action button Received Crate and write the below code. Here, “Crate Lines” is the Page control (subform), Here a call is made to CallLinesfromCard  function with Parameter CratesLine. CallLinesfromCard is a global function made in “Crate Lines”Subform. 2. In the function CallLinesfromCard  in the subform. Below is the code. Here ReceiveCrate is a page. Its the page that open on click of the action button. A function is called CrateReceivedFromCust with parameter CrateLinesTable. 3. A global function is made CrateReceivedfromCust in the page ReceiveCrate. Here global fields variables are made CustomerID,CustomerName,NoOfcratesShipped. Theses fields are autopopulated with values from the selected line. A field Crates Received is also created where the user will enter data. 4. OnQueryClosePage of Receive Page, below code is written to modify the Record of the Subform. 5. Set the property RefreshOnactive to yes on the Subform and Mainform.

Share Story :

How to restrict an action button based on time in Microsoft Dynamics NAV

Introduction: Scenario- The requirement was such that on click of the action button a payment transaction is done. The time at which transaction was done is stored in the database. A restriction shouldto be applied to disallow the customer to make payment for the same amount till a certain time E.g. A transaction was  done by customer A at 11.40 a.m for amount $100. This customer will be disallowed to make the transaction of the same amount $100 till suppose 5 mins. This time is mins will depend on the client requirement. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: A field is added in the Sales & recivable setup for Time Check in mins. Here, time in minutes is entered say 5 mins. So the payment will be restricted for 5 mins. I’ve written the code on the action button. EFTTransaction.RESET; EFTTransaction.SETRANGE(“Store No.”,’xyz’); EFTTransaction.SETRANGE(“Terminal No.”,’TERM01′); EFTTransaction.SETRANGE(“Sell-to Customer No.”,Rec.”Sell-to Customer No.”); EFTTransaction.SETRANGE(“Account Number”,Rec.”Account Number”); EFTTransaction.SETRANGE(“Transaction Amount”,Rec.”Transaction Amount”); EFTTransaction.SETRANGE(“Transaction Status”,EFTTransaction.”Transaction Status”::Approved); IF EFTTransaction.FINDLAST THEN BEGIN time1:=EFTTransaction.”Transaction Time”; Create Integer variables Hours, Minutes and Seconds and Milliseconds as Decimal variable. Get the transaction time. Time by default is stored in the system in milliseconds. The below code will convert time and store the hour in Hour variable, minutes in Minutes variable and same for seconds. //Code written to convert time to hr min and sec **ST** Milliseconds := time1 – 000000T; //MESSAGE(‘%1 total mili’,Milliseconds); Hours := Milliseconds DIV 1000 DIV 60 DIV 60; Milliseconds -= Hours * 1000 * 60 * 60; Minutes := Milliseconds DIV 1000 DIV 60; Milliseconds -= Minutes * 1000 * 60; Seconds := Milliseconds DIV 1000; Milliseconds -= Seconds * 1000 ; //Code written to convert time to hr min and sec **EN** Get the Time check in mins from Sales & recivable setup and add it up with the Minutes variable. “Rec_Sales&Rec”.GET; Minutes+=”Rec_Sales&Rec”.”Time Check for Credit Card(min”; Now we have till which the transaction should be restricted but the time is stored in Integer variables. Write the below code to convert the integer/decimal variable to time. Milliseconds+=Seconds*1000 +Minutes * 1000 * 60+Hours * 1000 * 60 * 60; //convert time to milliseconds Milliseconds:=Milliseconds/1000; //convert milliseconds to seconds tim := 000000T; tim := tim + (Milliseconds MOD 60) * 1000; // get the seconds Milliseconds := Milliseconds DIV 60; // keep the minutes tim := tim + (Milliseconds MOD 60) * 1000 * 60; // get the minutes Milliseconds := Milliseconds DIV 60; // keep the hours tim := tim + (Milliseconds MOD 60) * 1000 * 60 * 60; // get the hours Here we get our time in time variable. Add the restriction condition. IF (EFTTransaction.”Transaction Date”=TODAY) AND (TIME < tim) THEN ERROR(‘The Transaction for the account number %1 can be only done after %2 mins’,Rec.”Account Number”,”Rec_Sales&Rec”.”Time Check for Credit Card(min”) ELSE BEGIN Submit; “Submit&Settle”; Conclusion : Thus using the above logic time can be converted to Integer variables and then convert Integer variables to time again.

Share Story :

How to setup D365 Business Central?

Introduction: The much awaited Dynamics 365 Business Central officially released on 2 April 2018. We are often used to creating virtual machines and setting up Microsoft Dynamics NAV but D365 Business Central doesn’t require a VM, we can set it up on Azure and use it locally. Pre-requisites: Microsoft Azure Licence File Steps: 1. Create a resource group in Microsoft Azure. I have named it navbc. 2. Click on NAVBC resource group and open Azure cloud shell Enter the below command az container create –name MDBC  –image “microsoft/dynamics-nav:12.0.21229.0″ –resource-group NAVBC –os-type Windows –cpu 2 –memory 3 –environment-variables ACCEPT_EULA=Y USESSL=N LICENSEFILE=” ” –ip-address public –port 80 443 8080 7049 Here, –name: your container name –resource-group: your resource group name –environment-variables ACCEPT_EULA=Y – mandatory parameter. –ip-address public: mandatory LICENSEFILE=” ” : Here upload your licence to the cloud and then copy the link. –port: list of ports. 8080 is a default value. Use 7049 port number to download symbols whichout which you cannot connect VS code to your container Open your Resource group, the container instace is created click on the instance. This will open the container instance overview page. This will take quite some time approx 15-30 mins get your container instance running. For more information on azure commands click https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quickstarthere 3. To get the container infomation enter the below command az container logs –resource-group navbc –name mdbc 4. Download .vsix file Open your container Instance you will find your IP address. copy it. Copy the link under Files http://<containerIP>:8080/al-0.15.18771.vsix and replace b08..  with the conatiner IP address.This will download your .vsix file. now launch your VSCode and click on Extensions. Install .vsix and AL Language for D365 BC. 5. Publish an Extension Open the launch.json file and replace the server with “http://containerip”. Download symbols using command Ctrl+P Build(ctrl+shift+B) the package and publish it! (Ctrl+ F5). Yay! Now the final step open D365 Business Central. (http://containerip/NAV) This will prompt you for User name and pass word and bang D365 Business Central opens.

Share Story :

How to hide the Delete button in a page in Microsoft Dynamics NAV

Introduction: By default, Delete button is visible on every page in the Home tab but if we do not want the user to delete any record from the page then we need to hide this delete button. This article explains how to hide the Delete button from the Home tab of  page. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. Open the Microsoft Dynamics NAV Development Environment, navigate to the List Page where you want hide the delete button and go to properties of the page. 2. Set the DeleteAllowed property to No.  3. Repeat the step 1 and 2  for the Card page 4. Save and Compile the page. 5. We can hide the Edit button by setting InsertAllowed to No and ModifyAllowed Property to No  

Share Story :

Error Resolution to “Form.RunModal is not allowed in write transaction” in Microsoft Dynamics NAV

Introduction: Scenario: I had created an action button Print to run a report using REPORT.RUNMODAL, while running this report from the Windows Client an error is thrown as below. Pre-requisites: Microsoft Dynamics NAV 2017 Cause of this error: RUNMODAL stops the  transaction and waits for the User interaction. Hence, all users are blocked (who need the table). During a transaction, we are not allowed to open a object with RUNMODAL. Resolution to the error: Use COMMIT statement before you call the REPORT.RUNMODAL. What does COMMIT statement do? When the system enters a C/AL codeunit, it automatically enables write transactions to be performed. When the system exits a C/AL code module, it automatically ends the write transaction by committing the updates made by the C/AL code. This means that if you want the C/AL codeunit to perform a single write transaction, the system automatically handles it for you. However, if you want the C/AL codeunit to perform multiple write transactions, you must use the COMMIT function to end one write transaction before you can start the next. The COMMIT function separates write transactions in a C/AL code module. Example The metasyntax below contains two write transactions. As execution begins, a write transaction is automatically started. Using the COMMIT function, you tell the system that the first write transaction has ended and prepare the system for the second. Once execution has been completed, the system automatically ends the second write transaction. BeginWriteTransactions (C/AL Statements) // Transaction 1 COMMIT (C/AL Statements) // Transaction 2 EndWriteTransactions

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange